package com.kvest.multiframe_test.fragment;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.kvest.multiframe_test.R;

/**
 * Created with IntelliJ IDEA.
 * User: Kvest
 * Date: 23.03.13
 * Time: 14:40
 * To change this template use File | Settings | File Templates.
 */
public class ContentFragment extends Fragment {
    private static final String POSITION_KEY = "position";
    public static ContentFragment newInstance(int position) {
        ContentFragment result = new ContentFragment();

        Bundle arguments = result.getArguments();
        if (arguments == null) {
            arguments = new Bundle();
        }
        arguments.putInt(POSITION_KEY, position);
        result.setArguments(arguments);

        return result;
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.content_layout, null);
        ((TextView)view.findViewById(R.id.content_tv)).setText(getResources().getStringArray(R.array.content)[getPosition()]);

        return view;
    }

    public int getPosition() {
        return getArguments().getInt(POSITION_KEY);
    }
}
